package com.zzf.concurrent.example.ticket;

import com.zzf.concurrent.example.ticket.bean.TicketRunnable;

/**
 * @author GaoFeng2017
 * @date 2019/8/4 22:13
 */
public class TicketExampleV2 {

    public static void main(String[] args) {

        // 使用Runnable接口进行解耦
        /*
         * 不加延时时，号数不会变多
         * 在输出号数前加入随机延时，号数会增多
         * 在输出号数后加入随机延时，号数不会增多
         */
        TicketRunnable ticketRunnable = new TicketRunnable();
        Thread thread1 = new Thread(ticketRunnable, "柜台1");
        Thread thread2 = new Thread(ticketRunnable, "柜台2");
        Thread thread3 = new Thread(ticketRunnable, "柜台3");

        thread1.start();
        thread2.start();
        thread3.start();

    }
}
